﻿/**
 * 
 */
package com.zit.presentation.action;

import com.zit.entity.Teacher;
import com.zit.service.TeacherService;
import com.zit.util.MD5;
import com.zit.util.SystemUtil;

/**
 * 功能:教师登录、退出
 * @author 唐美兰
 * @datetime 2013-12-3
 * 
 */
public class LoginAction extends BaseAction{
	
	//登录教师对象
	private Teacher teacher;
	
	//实例化TeacherService
	private TeacherService teacherService = new TeacherService();

	/**
	 * 功能:用户登录
	 * @return
	 */
	public String login(){
		//将密码转换成MD5字符串
		teacher.setPassword(MD5.md5(teacher.getPassword()));
		//查询教师是否存在
		teacher = teacherService.login(teacher);
		if(teacher==null){//不存在
			return "loginError";
		}
		sessionMap.put(SystemUtil.LOGINUSER, teacher);
		return SUCCESS;
	}
	
	public Teacher getTeacher() {
		return teacher;
	}

	public void setTeacher(Teacher teacher) {
		this.teacher = teacher;
	}
}
